
<!--
  /**************************************************
  * @ addUnbalancedetail.jsp
  *
  * Copyright   2006 Hitrust Technology Inc.
  * Developed by SDC, Hitrust.
  * All Rights Reserved.
  *
  * Modify History:
  *  v1.00, 2006/06/06, Jenny Li
  *  1) first release
  *  v1.10  2006/06/11, Jenny Li
  *  1) 添加显示字段
  *  2)解决分页显示问题
  /**************************************************
-->
<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<html>
<head>
<title>订单管理</title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--<LINK href="<%=root%>/css/css.css" type=text/css rel=stylesheet>-->
<LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>
<%
		ResultProcess tOrder = (ResultProcess) request.getAttribute("order");
		ArrayList tManuf1 = (ArrayList) request.getAttribute("manufacture1");
		HashMap tMap1 = (HashMap) request.getAttribute("manufacturetyp2");
		HashMap tMap2 = (HashMap) request.getAttribute("manufacturetyp3");
		ArrayList tList = new ArrayList();
		String[] tStr = null;
%>
<SCRIPT language="JavaScript">
     <%
          if(message!=null){
              out.println("window.opener.location.href=window.opener.location.href;");
              out.println("window.close();");
          }
     %>
	 function process(val){
		if(val == 'Q'){
			var tStr = "";
			var tEnd = "";
			if(!isEmpty(ordertraceform.orderCreateDateStr.value)){
				tStr = ordertraceform.orderCreateDateStr.value.substr(0,4) + ordertraceform.orderCreateDateStr.value.substr(5,2) + ordertraceform.orderCreateDateStr.value.substr(8,2);

			}
			if(!isEmpty(ordertraceform.orderCreateDateEnd.value)){
				tEnd = ordertraceform.orderCreateDateEnd.value.substr(0,4) + ordertraceform.orderCreateDateEnd.value.substr(5,2) + ordertraceform.orderCreateDateEnd.value.substr(8,2);
			}
			if(parseInt(tStr) > parseInt(tEnd)){
					alert("订单创建周期的开始日期不能大于截至日期！");
					return false;
			}
			ordertraceform.action = "<%=response.encodeURL(root+"/A180219.do")%>";
    		ordertraceform.submit();
		}else if(val == 'C'){
			ordertraceform.orderDetailId.value ="";
			//ordertraceform.deliverGoodsId.value="";
			ordertraceform.orderType.value="0000";
			ordertraceform.concentricityId.value = "";
			ordertraceform.manufInfo.value = "";
			ordertraceform.orderCreateDateStr.value = "";
			ordertraceform.orderCreateDateEnd.value = "";
			ordertraceform.manuftype1.value="0";
            ordertraceform.deliverGoodsId.value="";
			listbox = document.getElementById("manuftype2");
			listbox.length = 0;
			option = new Option();
			option.text = "---二级---";
			option.value = "0";
			listbox.options[listbox.length] = option;
			listbox = document.getElementById("manuftype3");
			listbox.length = 0;
			option = new Option();
			option.text = "---三级---";
			option.value = "0";
			listbox.options[listbox.length] = option;
			return false;
		}else if(val == 'S'){
			if(document.pager.index != null){		
				if(!isCheckBoxselected(pager,pager.index)){
					return false;			
				}else{
					if(!confirm("是否确定将所选订单加入到本月结算信息中？")){
						return false;
					}else{
						pager.action = "<%=response.encodeURL(root + "/A180220.do")%>";
						pager.submit();
					}
				}			
			}
		}
	}
	var counter;
	function change1(optval){
	  var val = optval;
	  if(val=='0'){
	    var listbox = document.getElementById("manuftype2");
	    listbox.length = 0;
	    var option = new Option();
	    option.text = "---二级---";
	    option.value = "0";
	    listbox.options[listbox.length] = option;
	    change2(optval);
	  }else{
	      var counter="0";
	    <%if(tMap1 !=null){
	      Collection tCollection = tMap1.keySet();
	      Iterator tIterator = tCollection.iterator();
	      while(tIterator.hasNext()){
	        String tKey = (String)tIterator.next();
	        tList = (ArrayList)tMap1.get(tKey);%>
	        if(val == '<%=tKey%>'){
			  counter = "1";
	          var listbox = document.getElementById("manuftype2");
	          listbox.length = 0;
	          var option = new Option();
	          option.value = "0";
	          option.text = "---二级---";
	          listbox.options[listbox.length] = option;
	          <%
		          	for(int n=0;n<tList.size();n++){
			            GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList.get(n);
			            String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
			            String categoryName = tGSManufactureBean.getGs_manufacture_category_name();%>
			            var temp1 = '<%=categoryId%>';
			            var temp2 = '<%=categoryName%>';
			            var option = new Option();
			            option.value = temp1;
			            option.text = temp2;
			            listbox.options[listbox.length] = option;
	           <%
		       		}
	           %>
				change2('0');           
	         }
	         
	    <%
	    	}
	    %>
	    	if(counter == '0'){
	          var listbox = document.getElementById("manuftype2");
	          listbox.length = 0;
	          var option = new Option();
	          option.value = "0";
	          option.text = "---二级---";
	          listbox.options[listbox.length] = option;  
	          change2('0');    	
	    	}
	    <%  
	    }
	    %>
	   }
	}
    function change2(optval){
      var val = optval;
      if(val=='0'){
        var listbox = document.getElementById("manuftype3");
        listbox.length = 0;
        var option = new Option();
        option.text = "---三级---";
        option.value = "0";
        listbox.options[listbox.length] = option;

      }else{
      	var counter = "0";
        <%if(tMap2 !=null){
          Collection tCollection = tMap2.keySet();
          Iterator tIterator = tCollection.iterator();
          while(tIterator.hasNext()){
            String tKey = (String)tIterator.next();
            tList = (ArrayList)tMap2.get(tKey);%>
            if(val == '<%=tKey%>'){
              counter = "1";
              var listbox = document.getElementById("manuftype3");
              listbox.length = 0;
              var option = new Option();
              option.text = "---三级---";
              option.value = "0";
              listbox.options[listbox.length] = option;
              <%for(int n=0;n<tList.size();n++){
                GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList.get(n);
                String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
                String categoryName = tGSManufactureBean.getGs_manufacture_category_name();%>
                var temp1 = '<%=categoryId%>';
                var temp2 = '<%=categoryName%>';
                var option = new Option();
                option.value = temp1;
                option.text = temp2;
                listbox.options[listbox.length] = option;
                <%}%>
              }
          <%
          }
          %>
          if(counter == '0'){
		        var listbox = document.getElementById("manuftype3");
		        listbox.length = 0;
		        var option = new Option();
		        option.text = "---三级---";
		        option.value = "0";
		        listbox.options[listbox.length] = option;          
          }
          <%
            }
          %>
          }
        }
</script>
</head>
<body LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0"
	MARGINHEIGHT="0">
<p><br>
</p>
<table width="98%" border="0" cellspacing="0" cellpadding="0"
	align="center">
	<tr>
		<td height="20">
		<table width="100%" border="0" cellspacing="0" cellpadding="1">
			<tr height="20">
				<td height="30" width="758" class="mtxt_black">订单查询</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="bg_line" height="2"></td>
	</tr>
</table>
<br>
<form name="ordertraceform" method="get">
<input type="hidden" name="balanceYM" value="<%=request.getAttribute("balanceYM")%>">
<table width="98%" border="0" cellspacing="0" cellpadding="0"
	align="center"></table>
<table class="bg_table" id="Table1" cellspacing="1" cellpadding="0"
	style="PADDING-RIGHT:5px;PADDING-LEFT:5px" width="98%" align="center"
	border="0">
	<TR height="20">
		<TD class="bg_column" align="center">订单明细编号</TD>
		<TD align="left" class="bg_row_odd" colspan="3"><input type="text" name="orderDetailId"
			value="<%=request.getParameter("orderDetailId")==null? "":request.getParameter("orderDetailId") %>">
		</TD>
	</TR>
	<TR height="20">
		<TD class="bg_column" align="center">集中编码</TD>
		<TD align="left" class="bg_row_odd"><input type="text"
			name="concentricityId"
			value="<%=request.getParameter("concentricityId")==null? "":request.getParameter("concentricityId") %>"></TD>
		<TD class="bg_column" align="center">供应商</TD>
		<TD class="bg_row_odd" align="left">
        <INPUT  type="text"	NAME="providerName" value="<%=request.getAttribute("proName")%>" disabled>
        <input type="hidden" name="proId" value="<%=request.getAttribute("proid") %>">
        </TD>
    </TR>
	<tr>
		<TD class="bg_column" align="center">产品信息</TD>
		<TD class="bg_row_odd" colspan="3"><INPUT type="text" NAME="manufInfo"
			value="<%=request.getParameter("manufInfo")==null? "":request.getParameter("manufInfo") %>">
		（ <FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商、附加属性等关键字的模糊查询</FONT> ） &nbsp;</TD>
	</tr>
	<TR height="20">
		<TD class="bg_column" align="center">产品分类</TD>
		<TD left="right" class="bg_row_odd" colspan="3"><select
			name="manuftype1" onChange="change1(this.value)">
			<option value="0">---一级---</option>
			<%String tManufType1 = request.getParameter("manuftype1");
			if (tManuf1 != null && tManuf1.size() > 0) {
				for (int i = 0; i < tManuf1.size(); i++) {
					GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean) tManuf1.get(i);
					if (tManufType1 != null && tManufType1.equals(tGSManufactureBean.getGs_manufacture_category_id())) {
			%>
			<option	value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>" selected>
				<%=tGSManufactureBean.getGs_manufacture_category_name()%>
			</option>
			<%
					} else {
			%>
			<option
				value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>"><%=tGSManufactureBean.getGs_manufacture_category_name()%>
			</option>
			<%
					}
				}
			}

			%>
		</select> 
		<select id="manuftype2" name="manuftype2"
			onChange="change2(this.value)">
			<option value="0">---二级---</option>
			<%String tManufType2 = request.getParameter("manuftype2");
		if (tManufType1 != null && !tManufType1.equals("0")) {
			ArrayList temp = (ArrayList) tMap1.get(tManufType1);
			if (temp != null && temp.size() > 0) {
				for (int i = 0; i < temp.size(); i++) {
					GSManufactureCategoryBean tGSManuf2 = (GSManufactureCategoryBean) temp.get(i);
					if (tManufType2 != null && tManufType2.equals(tGSManuf2.getGs_manufacture_category_id())) {
						%>
			<option value="<%=tManufType2%>" selected><%=tGSManuf2.getGs_manufacture_category_name()%>
			</option>
			<%} else {
						%>
			<option value="<%=tGSManuf2.getGs_manufacture_category_id()%>"><%=tGSManuf2.getGs_manufacture_category_name()%>
			</option>
			<%
					}
				}
			}
		}

		%>
		</select> 
		<select name="manuftype3" id="manuftype3">
			<option value="0">---三级---</option>
			<%String tManufType3 = request.getParameter("manuftype3");
		if (tManufType2 != null && !tManufType2.equals("0")) {
			//int tIntManufType3 = Integer.parseInt(tManufType3);
			ArrayList temp = (ArrayList) tMap2.get(tManufType2);
			if (temp != null && temp.size() > 0) {
				for (int i = 0; i < temp.size(); i++) {
					GSManufactureCategoryBean tGSManuf3 = (GSManufactureCategoryBean) temp.get(i);
					if (tManufType3 != null && tManufType3.equals(tGSManuf3.getGs_manufacture_category_id())) {
						%>
			<option value="<%=tGSManuf3.getGs_manufacture_category_id()%>"
				selected><%=tGSManuf3.getGs_manufacture_category_name()%></option>
			<%} else {
						%>
			<option value="<%=tGSManuf3.getGs_manufacture_category_id()%>"><%=tGSManuf3.getGs_manufacture_category_name()%>
			</option>
			<%
					}
				}
			}
		}
		%>
		</select></TD>
	</TR>
	<TR height="20">
		<TD class="bg_column" align="center">创建时间</TD>
		<TD align="left" class="bg_row_odd" colspan="3"><input type="text"
			name='orderCreateDateStr' size="20" readonly onfocus='setday(this)'
			value="<%=request.getParameter("orderCreateDateStr")==null? "":request.getParameter("orderCreateDateStr") %>">
		～ <input type="text" name='orderCreateDateEnd' size="20" readonly
			onfocus='setday(this)'
			value="<%=request.getParameter("orderCreateDateEnd")==null? "":request.getParameter("orderCreateDateEnd") %>"></TD>
	</TR>
	<TR height="20">
		<TD class="bg_column" align="center">送货单号</TD>
		<TD align="left" class="bg_row_odd"><INPUT type="text"
			NAME="deliverGoodsId"
			value="<%=request.getParameter("deliverGoodsId")==null? "":request.getParameter("deliverGoodsId") %>"></TD>
		<TD class="bg_column" align="center">订单类型</TD>
		<TD align="left" class="bg_row_odd"><select name="orderType">
			<option value="0000">---全部---</option>
			<%
		String[][] tOrderTypeList = GSBaseManager.getAllOrderCategory2();
		String tOrderType = request.getParameter("orderType");
		if (tOrderTypeList != null && tOrderTypeList.length > 0) {
			for (int i = 0; i < tOrderTypeList.length; i++) {
				String[] temp = (String[]) tOrderTypeList[i];
				if (tOrderType != null && tOrderType.equals(temp[0])) {
					%>
			<option value="<%=temp[0]%>" selected><%=temp[1]%></option>
			<%} else {
					%>
			<option value="<%=temp[0]%>"><%=temp[1]%></option>
			<%
				}
			}
		}

		%>
		</select></TD>
	</TR>
</table>
<%int totalRecords = 0;
if (tOrder != null) {
    if(request.getAttribute("totalRecords")!=null){
        totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
    }
    int defaultPageSize =10;
    if(request.getAttribute("pageSize")!=null){
        defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
    }
            tList = tOrder.getAllRecoreds();            
        %> 
            <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'></page:pager>
            <%} %>
</form>
<p align="center">
		<input type="button" name="查询" value="查询" class="kuang" onclick="process('Q')"/>&nbsp;
		<input type="button" name="清空" value="清空" class="kuang" onclick="process('C')"/>&nbsp;
</p>
<br>
<%

		if (tOrder != null) {

			%>
<table width="98%" border="0" cellspacing="0" cellpadding="0"
	align="center">
	<tr>
		<td>
            <form name='pager' method="post">
			<input type="hidden" name="totalRecords" value="<%=totalRecords%>">    
			<input type="hidden" name="balYM" value="<%=request.getAttribute("balanceYM")%>"> 
			<input type="hidden" name="deptId" value="<%=request.getAttribute("deptId")%>">			   
			<table class=bg_table id=tableId cellspacing=1 cellpadding=2 width=100% align=center border=0>
    
				<tbody>
				<%
					if(tList.size() > 0){
				%>
					<tr class="bg_column" height=20>
						<td width="960" height="16" colspan="19" align="right"><!--导航条-->
						<page:navigator type='text' queryForm="ordertraceform"/></td>
					</tr>				
				<%	
					}
				%>
					<tr class="bg_column" height="20">
						<td class="top" align="center" colSpan="19"><b>订单信息列表</b></td>
					</tr>
					<tr class="bg_column" height="20">
						<td class="top" align="center">
							<div align="center" class="txt_content"><INPUT type="checkbox" ID="Checkbox" NAME="indexs" onClick="SelectAllCheckBox(pager,'index')"></div>
						</td>					
						<td class="top" align="center">
						<div class="txt_content" align="center">订单明细编号</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">集中编码</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">产品名称</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">是否交易平台产品</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">规格</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">型号</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">品牌</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">供应商</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">订货数量</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">创建时间</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">订货单位</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">签收数量</div>
						</td>												
						<td class="top" align="center">
						<div class="txt_content" align="center">签收单价（元）</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">总价（元）</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">送货日期</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center">送货时间</div>
						</td>
                        <td class="top" align="center">
                        <div class="txt_content" align="center">结算模式</div>
                        </td>
						<td class="top" align="center">
						<div class="txt_content" align="center">详细</div>
						</td>
					</tr>
		<%
			if (tList != null && tList.size() > 0) {
				for (int i = 0; i < tList.size(); i++) {
				    GSAddUnBalanceDetailQryResultVO tGSOrderVO = (GSAddUnBalanceDetailQryResultVO) tList.get(i);
					String tTempStr = "";
					if (i % 2 == 0) {
						tTempStr = "class=\"bg_row_odd\"";
					} else {
						tTempStr = "class=\"bg_row_even\"";
					}
					int size = 0;
		%>
					<tr <%=tTempStr%> height=20>
						<td class="top" align="center">
							<div align="center" class="txt_content">
							<INPUT type="checkbox" NAME="index" value="<%=tGSOrderVO.orderDetailId%>"></div>
							<input type="hidden" name="orderDetailIds" value="<%=tGSOrderVO.orderDetailId%>">									
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.orderDetailId%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><FONT face="宋体"><%=tGSOrderVO.concentricity%></FONT>
						</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><a
							href="<%=response.encodeURL(root+"/A150103.do")%>?concentricityId=<%=tGSOrderVO.concentricity%>"
							target="_blank"><%=tGSOrderVO.manufName%></A></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=GSBaseManager.getIsTradeManuf(tGSOrderVO.isTradeFlatManuf)%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.spec%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.type%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.brand%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><a
							href="<%=response.encodeURL(root+"/A400108.do")%>?providerId=<%=tGSOrderVO.providerId%>"
							target="_blank"><%=tGSOrderVO.providerName%></a>
							<%=(tGSOrderVO.isTradeFlatManuf.equals("0")&&tGSOrderVO.isTradeFlatProvider.equals("0") ? "（采购网配送）" : "")%>
						</div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=new DecimalFormat("0.00").format(tGSOrderVO.orderCount)%><%=tGSOrderVO.quantUnit%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.orderCreateDate%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.deptName%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=new java.text.DecimalFormat("0.00").format(tGSOrderVO.signCount)+tGSOrderVO.quantUnit%></div>
						</td>												
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=new java.text.DecimalFormat("0.0000").format(tGSOrderVO.goodsUnitPrice)%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=new java.text.DecimalFormat("0.0000").format(tGSOrderVO.orderCount * tGSOrderVO.goodsUnitPrice)%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=tGSOrderVO.deliverGoodsDate%></div>
						</td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><%=GSBaseManager.getDeliverGoodsTime(tGSOrderVO.deliverGoodsTime)%></div>
						</td>
                        <td class="top" align="center">
                        <div class="txt_content" align="center">
                        <%=DefineDic.getBalanceMode(tGSOrderVO.mode) %>
                        </div>
                        </td>
						<td class="top" align="center">
						<div class="txt_content" align="center"><a
							href="<%=response.encodeURL(root+"/A150505.do")%>?orderId=<%=tGSOrderVO.orderId%>&orderDetailId=<%=tGSOrderVO.orderDetailId%>"
							target="_blank">详细</A></div>
						</td>
					</tr>
					<%
				}

			%>
					<tr class="bg_column" height=20>
						<td width="960" height="16" colspan="19" align="right"><!--导航条-->
						<page:navigator type='text' queryForm="ordertraceform"/></td>
					</tr>
					<%} else {

			%>
					<font color="red">没有符合条件的产品订单信息</font>
					<%}

		%>
				</tbody>
			</table>
		</form></td>
	</tr>
</table>
<center>
<p>
	<tr>
		<td align="center">
			<INPUT type="button" value="加入本月结算" class="kuang" onClick="process('S')">&nbsp; 					
			<INPUT type="button" value="关闭" class="kuang" onClick="window.close();">&nbsp; 
		</td>
	</tr>
</p>
</center>
<%}
%>
</body>
</html>
